ScrapBubble for TamperMonkey
takker.icon用の設定
code:script.js
// ==UserScript==
// @name ScrapBubble
// @namespace https://scrapbox.io
// @version 0.3.1
// @description n hop先のテキストを表示する
// @author takker
// @downloadURL https://scrapbox.io/api/code/takker-dist/ScrapBubble_for_TamperMonkey/tampermonkey.js
// @updateURL https://scrapbox.io/api/code/takker-dist/ScrapBubble_for_TamperMonkey/tampermonkey.js
// @match https://scrapbox.io/*
// @exclude https://scrapbox.io/settings
// @license MIT
// @unwrap
// @copyright Copyright (c) 2021 takker
// ==/UserScript==
window.addEventListener("load", async () => {
// #editorが読み込まれるまで待機
// cf. https://scrapbox.io/scrapbox-drinkup/puppeteerでscrapboxを自動化してイテレーション資料を宣言的に完成させる_(2019%2F9%2F5)
await new Promise(resolve => {
let timer = null;
timer = setInterval(() => {
if (!document.getElementById('editor')) return;
clearInterval(timer);
resolve();
}, 1000);
});
// 念の為1秒くらい待っとく
await new Promise((resolve) => setTimeout(() => resolve(), 1000));
const res = await fetch('/api/projects');
const { projects } = await res.json();
if (projects.map(({ name }) => name).includes(scrapbox.Project.name)) {
console.info(You belong to "/${scrapbox.Project.name}".);
return;
}
console.info(You don't belong to "/${scrapbox.Project.name}". Loading ScrapBubble via TamperMonkey...);
const code = "/api/code/takker-dist/ScrapBubble-min/app.js"
const { mount } = await import(code);
const whiteList = "takker-memex", "takker-private", "takker", "takker-PS", "NDLSH-SB";
switch (scrapbox.Project.name) {
case "hub":
case "villagepump":
case "verbalizing-community":
whiteList.push("villagepump", "hub", "verbalizing-community");
break;
case "programming-notes":
case "customize":
case "scrapboxlab":
whiteList.push("programming-notes", "customize", "scrapboxlab");
break;
case "sta":
whiteList.push("sta-taskmanagement");
break;
case "sta-taskmanagement":
case "taskmanagement":
whiteList.push("sta-taskmanagement", "taskmanagement");
break;
}
mount({ whiteList });
}, { once: true });